﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using JLL.China.Infrastructure.Services;
using JLL.China.Model;
using JLL.China.Model.DTO;
using JLL.China.Web.Areas.Listings.Models;
using JLL.China.Web.Libraries;
using JLL.China.Infrastructure.Repositories.LINQ2SQL;
using System.Web.Configuration;
namespace JLL.China.Web.Areas.Listings.Controllers
{
    public class PropertyController : ListingController
    {
        
        public PropertyController()
        {
            ViewData["now_controller"] = "Listings/Property/";
            ViewData["ActionPost"] = "Property";
            ViewData["ListingType"] = "Resale";
            ViewData["IsLocal"] = "LOCAL";
            ViewData["ListingSource"] = "Admin";
            ViewData["Title"] = "View Listings(Local)";
            ViewData["controller"] = "Property";
            //Messeage
            ViewData["HeadingMsgStep1"] = " Property Listings - Basic Details ";
            ViewData["HeadingMsgStep2"] = " Property Listings - Project Detail ";
            ViewData["HeadingMsgStep3"] = " Property Listings - Features & Facilities ";
            ViewData["HeadingMsgStep4"] = " Property Listings - Map ";
            ViewData["HeadingMsgStep5"] = " Property Listings - Media ";
            ViewData["HeadingMsgStep6"] = " Property Listings - Floor plan ";
        }

  
        //
        // GET: /Listings/Property/
        //Local
        public ActionResult Index(int? id,int? page)
        {
            if (Session["page_size_default"] != null)
            {
                ViewData["per-page"] = Session["page_size_default"].ToString();
                defaultPageSize = Int32.Parse(Session["page_size_default"].ToString());
            }
            else
            {
                ViewData["per-page"] = defaultPageSize;
            }
            int currentPageIndex = page.HasValue ? page.Value : 1;
            //Strore Session
            Session["heading"] = "Manage Property Listings";
            Session["pageindex"] = currentPageIndex;
            if (id != null)
            {
                ViewData["ListStatus"] = id.ToString();
            }
            else
            {
                id = null;
                ViewData["ListStatus"] = 0;
            }
             
            var property = new ListingModel();
            
            var model = property.GetPropertyByStatus(id).ToPagedList(currentPageIndex, defaultPageSize);

           return View(model);
        }
       
       
    }
}
